import 'package:flutter/material.dart';


class TabInfoGrid extends StatelessWidget {
  final String titleName;
  const TabInfoGrid({Key key, this.titleName}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GridView.count(
        //水平子Widget之间间距
        crossAxisSpacing: 10.0,
        //垂直子Widget之间间距
        mainAxisSpacing: 30.0,
        //GridView内边距
        padding: EdgeInsets.all(10.0),
        //一行的Widget数量
        crossAxisCount: 2,
        //子Widget宽高比例
        childAspectRatio: 2.0,
        //子Widget列表
        children: getWidgetList(titleName),
      );
  }
}

List<String> getDataList() {
    List<String> list = [];
    for (int i = 0; i < 100; i++) {
      list.add(i.toString());
    }
    return list;
  }

  List<Widget> getWidgetList(titleName) {
    String titlename = titleName ?? "";

    return getDataList().map((item) => getItemContainer(titlename + item )).toList();
  }

  Widget getItemContainer(String item) {
    return Container(
      alignment: Alignment.center,
      child: Text(
        item,
        style: TextStyle(color: Colors.white, fontSize: 20),
      ),
      decoration: BoxDecoration(
        gradient: LinearGradient(
          colors: <Color>[
          Color(0xFFCC95C0),
          Color(0xFFDBD4B4),
          Color(0xFF7AA1D2)
        ]
      ) 
      ),
     
    );
  }
